<template>
  <div class="tryList_detail">
    <div class="item-header item-box">
      <h1 class="apply-status clearfix">您的申请状态<b>{{detail.status_name}}</b></h1>
      <div class="header-info"
           v-if="detail.reject_reason">
        <p><b>拒绝理由：</b></p>
        <p>{{detail.reject_reason}}</p>
      </div>
      <!-- 拒绝时显示 -->
    </div>

    <dl class="item-wrap item-box">
      <dt>收货地址</dt>
      <dd>{{detail.province_id}}{{detail.city_id}}{{detail.area_id}}{{detail.address}}{{detail.name}}{{detail.mobile}}</dd>
    </dl>
    <!-- 发货时显示 -->

    <dl class="item-wrap item-box">
      <dt>活动信息</dt>
      <dd>{{detail.act_title}}</dd>

      <div class="goods_box">
        <section class="morder_goods">
          <ul>
            <li class="g-box">
              <section class="morder_goods_img" @click="jumpTo(detail.item_id)">
                <img :src="detail.pic_url"
                     :alt="detail.title" />
              </section>
              <section class="morder_goods_infor g-flex">
                <!-- TODO 小程序跳转处理 -->
                <a @click="jumpTo(detail.item_id)">{{detail.title}}</a>
                <p class="detail_props">{{detail.props}}</p>
                <p class="morder_goods_price">¥<em>{{detail.price}}</em></p>
              </section>
            </li>
          </ul>
        </section>
      </div>
      <dd class="time">
        <p>开始时间：{{detail.start_time}}</p>
        <p>结束时间：{{detail.end_time}}</p>
      </dd>
    </dl>

    <dl class="item-wrap item-box">
      <dt>参与要求</dt>
      <dd>
        <div class="dd-item clearfix">
          <span class="fl">{{detail.point_name}}要求</span>
          <span class="fr">{{detail.points}}</span>
        </div>
        <div class="dd-item clearfix">
          <span class="fl">等级要求</span>
          <span class="fr">{{detail.rank_name}}</span>
        </div>
      </dd>
    </dl>

    <dl class="item-wrap item-box">
      <dt>当前活动状态</dt>
      <dd>
        <div class="dd-item clearfix">
          <span class="fl">已参与人数</span>
          <span class="fr">{{detail.apply_num}}人</span>
        </div>
        <div class="dd-item clearfix">
          <span class="fl">同意试用</span>
          <span class="fr">{{detail.agree_num}}人</span>
        </div>
      </dd>
    </dl>
    <dl class="item-wrap item-box"
        v-if="detail.express_no">
      <dt>快递单号</dt>
      <dd class="clearfix">
        <span class="fl dd-item">
          {{detail.express_name?detail.express_name+'：':''}}{{detail.express_no}}
        </span>
      </dd>
    </dl>
    <dl class="item-wrap item-box"
        v-if="detail.express_track">
      <dt>物流详情</dt>
      <dd class="logistics">
        <span v-for="(track_vo,index) in detail.express_track "
              :key="index"
              class="wuliu"
              :class="index==0 ?'cur':''">
          <div class="wlt">
            <p>
              {{track_vo.context?track_vo.context:track_vo.list['2']}}
            </p>
            <p>
              {{track_vo.time?track_vo.time:track_vo.list['1']}}
            </p>
          </div>
        </span>
      </dd>
    </dl>
  </div>
</template>

<script>
import Vue from 'vue'
import { getTryListDetail } from '@/api/user/member/memberApi'

export default Vue.extend({
  data() {
    return {
      detail: {}
    }
  },
  methods: {
    // TODO 小程序跳转修改
    jumpTo(detailId) {
        window.open('/item-detail?detailId=' + detailId)
    },
    init() {
      const data = { id: this.$route.query.id }
      this.$loadingWrap.show()
      getTryListDetail(data).then(res => {
        this.$loadingWrap.close()
        if (res.status == 1) {
          this.detail = res.data
        } else {
          this.$Error(res.msg)
        }
      })
    }
    // },
    // getPriceInt(price) {
    //   if (price) {
    //     const idx = price.indexOf('.')
    //     return idx !== -1 ? price.substr(0, idx) : price
    //   } else {
    //     return '0'
    //   }
    // },
    // getPriceDot(price) {
    //   if (price) {
    //     const idx = price.indexOf('.')
    //     return idx !== -1 ? price.substr(idx) : '.00'
    //   } else {
    //     return '.00'
    //   }
    // }
    // _toFixed(num) {
    //   return num ? num.toFixed(2) : '0.00'
    // }
  },

  created() {
    this.init()
  }
})
</script>
<style lang="scss">
.tryList_detail {
  padding-bottom: 20px;
  .item-box {
    background: #fff;
    box-shadow: 0 0 2px rgba(0, 0, 0, 0.1);
    color: #666;
  }
  .item-header {
    padding: 30px 0;
    font-size: 28px;
    h1 {
      font-size: 28px;
      margin: 0;
    }
    .apply-status {
      padding: 0 30px;
      background: #fff;
      color: #666;
      b {
        float: right;
        color: #ff5a00;
      }
    }
    .header-info {
      background: #fff;
      padding: 20px 30px;
      border-bottom: 2px solid #e9e9e9;
      line-height: 40px;
    }
  }
  .item-wrap {
    margin-top: 20px;
    font-size: 28px;
    dt {
      padding: 24px 30px;
      border-bottom: 2px solid #f3f3f3;
      color: #333;
    }
    dd {
      padding: 24px 30px;
      line-height: 40px;
      &.time {
        font-size: 24px;
      }
    }
  }
  .goods_box {
    background: #f5f5f5;
    .morder_goods {
      font-size: 24px;
      background: #f5f5f5;
      li {
        border-bottom: none;
        display: flex;
        padding: 14px 0;
      }
    }
    .morder_goods_img {
      margin-left: 30px;
      width: 160px;
      height: 160px;
      overflow: hidden;
      position: relative;
      border-radius: 10px;
      img {
        width: 100%;
      }
    }
    .morder_goods_infor {
      display: flex;
      display: -webkit-box;
      display: -webkit-flex;
      flex-direction: column;
      -webkit-flex-direction: column;
      -moz-flex-direction: column;
      justify-content: space-between;
      -webkit-justify-content: space-between;
      -moz-justify-content: space-between;
      margin: 0 30px;
    }
    .morder_goods_infor a {
      display: block;
      width: 100%;
      height: auto;
      font-size: 24px;
      line-height: 32px;
      color: #333333;
      overflow: hidden;
      text-overflow: ellipsis;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }
    .detail_props {
      color: #999;
      width: 100%;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
    }
    .morder_goods_price {
      margin-left: 6px;
      color: #ff5a00;
      em {
        font-size: 32px;
        display: inline-block;
      }
    }
  }
}
</style>
<style lang="scss">
@import "src/styles/variables.scss";
@import "src/styles/mixin";
</style>